<html>
<head><meta charset="utf-8"><title>failed to run stage0 rustc - why? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html">failed to run stage0 rustc - why?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196893739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196893739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196893739">(May 08 2020 at 13:14)</a>:</h4>
<p>I'm trying to understand an error I got on CI: <a href="https://github.com/rust-lang/rust/pull/71994#issuecomment-625539912" title="https://github.com/rust-lang/rust/pull/71994#issuecomment-625539912">https://github.com/rust-lang/rust/pull/71994#issuecomment-625539912</a><br>
I can reproduce locally, but I have no idea why it fails. The only error message is</p>
<div class="codehilite"><pre><span></span><code> failed to run &quot;build/x86_64-unknown-linux-gnu/stage0/bin/rustc&quot; &quot;--crate-name&quot; &quot;cc&quot; &quot;--edition=2018&quot; &quot;/cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50/src/lib.rs&quot; &quot;--error-format=json&quot; &quot;--json=diagnostic-rendered-ansi&quot; &quot;--crate-type&quot; &quot;lib&quot; &quot;--emit=dep-info,metadata,link&quot; &quot;-C&quot; &quot;opt-level=3&quot; &quot;-C&quot; &quot;debuginfo=0&quot; &quot;-C&quot; &quot;metadata=9e7bf81b9fe8db6d&quot; &quot;-C&quot; &quot;extra-filename=-9e7bf81b9fe8db6d&quot; &quot;--out-dir&quot; &quot;/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-std/release/deps&quot; &quot;-L&quot; &quot;dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-std/release/deps&quot; &quot;--cap-lints&quot; &quot;allow&quot; &quot;-Zbinary-dep-depinfo&quot;&#39;, src/bootstrap/bin/rustc.rs:205:54
</code></pre></div>


<p>but when I run that command locally it works! (or at least I assume it works since there's no output and exits with 0) Does anyone have ideas?</p>



<a name="196893907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196893907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196893907">(May 08 2020 at 13:16)</a>:</h4>
<p>Or hold on it only works if I have <code>RUSTC_BOOTSTRAP=1</code> in the environment - maybe that wasn't set for some reason? I don't know what that has to do with my change though.</p>



<a name="196894775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196894775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196894775">(May 08 2020 at 13:25)</a>:</h4>
<p>It looks like the issue is environment variables aren't being set ... but I'm not sure why that could happen.</p>
<div class="codehilite"><pre><span></span><code>$ git diff
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 9e56dd3770d..5d6a877307a 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -677,7 +677,10 @@ class RustBuild(object):
         # See also: &lt;https://github.com/rust-lang/rust/issues/70208&gt;.
         if &quot;CARGO_BUILD_TARGET&quot; in env:
             del env[&quot;CARGO_BUILD_TARGET&quot;]
+        print(&quot;setting RUSTC_BOOTSTRAP=1&quot;)
         env[&quot;RUSTC_BOOTSTRAP&quot;] = &#39;1&#39;
+        print(&quot;setting RUST_BACKTRACE=1&quot;)
+        env[&quot;RUST_BACKTRACE&quot;] = &#39;1&#39;
         env[&quot;CARGO_TARGET_DIR&quot;] = build_dir
         env[&quot;RUSTC&quot;] = self.rustc()
         env[&quot;LD_LIBRARY_PATH&quot;] = os.path.join(self.bin_root(), &quot;lib&quot;) + \
$ ./x.py check
Updating only changed submodules
Submodules updated in 0.01 seconds
setting RUSTC_BOOTSTRAP=1
setting RUST_BACKTRACE=1
    Finished dev [unoptimized] target(s) in 0.12s
Checking rustdoc artifacts (x86_64-unknown-linux-gnu -&gt; x86_64-unknown-linux-gnu)
Checking clippy artifacts (x86_64-unknown-linux-gnu -&gt; x86_64-unknown-linux-gnu)
Checking std artifacts (x86_64-unknown-linux-gnu -&gt; x86_64-unknown-linux-gnu)
   Compiling cc v1.0.50
   Compiling libc v0.2.69
   Compiling autocfg v0.1.7
thread &#39;main&#39; panicked at &#39;

 failed to run &quot;build/x86_64-unknown-linux-gnu/stage0/bin/rustc&quot; &quot;--crate-name&quot; &quot;cc&quot; &quot;--edition=2018&quot; &quot;/home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50/src/lib.rs&quot; &quot;--error-format=json&quot; &quot;--json=diagnostic-rendered-ansi&quot; &quot;--crate-type&quot; &quot;lib&quot; &quot;--emit=dep-info,metadata,link&quot; &quot;-C&quot; &quot;opt-level=3&quot; &quot;-C&quot; &quot;debuginfo=0&quot; &quot;-C&quot; &quot;metadata=9e7bf81b9fe8db6d&quot; &quot;-C&quot; &quot;extra-filename=-9e7bf81b9fe8db6d&quot; &quot;--out-dir&quot; &quot;/home/joshua/src/rust/build/x86_64-unknown-linux-gnu/stage0-std/release/deps&quot; &quot;-L&quot; &quot;dependency=/home/joshua/src/rust/build/x86_64-unknown-linux-gnu/stage0-std/release/deps&quot; &quot;--cap-lints&quot; &quot;allow&quot; &quot;-Zbinary-dep-depinfo&quot;&#39;, src/bootstrap/bin/rustc.rs:205:54
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: could not compile `cc`.
</code></pre></div>



<a name="196894933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196894933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196894933">(May 08 2020 at 13:26)</a>:</h4>
<p>I guess I can try applying my changes one at a time?</p>



<a name="196895595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196895595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196895595">(May 08 2020 at 13:32)</a>:</h4>
<p>ok this is the one that breaks things:</p>
<div class="codehilite"><pre><span></span><code>$ git diff
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 9e56dd3770d..80ef994ce64 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -906,6 +906,8 @@ def bootstrap(help_triggered):

     build.check_vendored_status()

+    build.build_dir = (build.get_toml(&#39;build-dir&#39;, &#39;build&#39;) or &#39;build&#39;).replace(&quot;$ROOT&quot;, build.rust_root)
+
     data = stage0_data(build.rust_root)
     build.date = data[&#39;date&#39;]
     build.rustc_channel = data[&#39;rustc&#39;]
</code></pre></div>



<a name="196895720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196895720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196895720">(May 08 2020 at 13:33)</a>:</h4>
<p>I suspect it's because your build_dir is not the same as the build/ directory bootstrap is expecting</p>



<a name="196895744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196895744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196895744">(May 08 2020 at 13:33)</a>:</h4>
<p>we look for the bootstrap compiler in something like root.join("build")... I think</p>



<a name="196895804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196895804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196895804">(May 08 2020 at 13:34)</a>:</h4>
<p>This should default to <code>build</code> though: <code>build.get_toml('build-dir', 'build') or 'build'</code></p>



<a name="196895827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196895827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196895827">(May 08 2020 at 13:34)</a>:</h4>
<p>maybe it needs to be relative to the current directory _at that time_ as opposed to at the time of the build?</p>



<a name="196895839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196895839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196895839">(May 08 2020 at 13:34)</a>:</h4>
<p>I can use <code>abspath</code> and see if that helps</p>



<a name="196895988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196895988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196895988">(May 08 2020 at 13:35)</a>:</h4>
<p>yay that did it <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="196896183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/failed%20to%20run%20stage0%20rustc%20-%20why%3F/near/196896183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/failed.20to.20run.20stage0.20rustc.20-.20why.3F.html#196896183">(May 08 2020 at 13:37)</a>:</h4>
<p>yeah I think that's right</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>